package uk.ac.cam.tcs40.sidnet.formal;

import uk.ac.cam.tcs40.sidnet.Hall;
import uk.ac.cam.tcs40.sidnet.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class FormalMenuFragment extends Fragment {

	private Formal m_Formal;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle extras = getActivity().getIntent().getExtras();

		String id;
		if (extras != null) {
			id = extras.getString("id");
			if (id != null) {
				m_Formal = Hall.getInstance().getFormal(id);
			}
		}
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		super.onCreateView(inflater, container, savedInstanceState);

		final View view = inflater.inflate(R.layout.activity_formal_menu, container, false);

		if (m_Formal != null) {
			if (m_Formal.getMenu() != null) {
				FormalMenu menu = m_Formal.getMenu();

				((TextView) view.findViewById(R.id.starter)).setText(menu.getStarter());
				((TextView) view.findViewById(R.id.main)).setText(menu.getMain());
				((TextView) view.findViewById(R.id.vegetarian)).setText(menu.getVegetarian());
				((TextView) view.findViewById(R.id.dessert)).setText(menu.getDessert());
			}
		}

		return view;
	}
}
